It's unused.
GDK_HINT_POS = 1 << 0,
GDK_HINT_MIN_SIZE = 1 << 1,
GDK_HINT_MAX_SIZE = 1 << 2,
- GDK_HINT_BASE_SIZE = 1 << 3,
GDK_HINT_ASPECT = 1 << 4,
- GDK_HINT_RESIZE_INC = 1 << 5,
GDK_HINT_WIN_GRAVITY = 1 << 6,
GDK_HINT_USER_POS = 1 << 7,
GDK_HINT_USER_SIZE = 1 << 8
int min_height;
int max_width;
int max_height;
- int base_width;
- int base_height;
- int width_inc;
- int height_inc;
double min_aspect;
double max_aspect;
GdkGravity win_gravity;
*/
int min_width = 0;
int min_height = 0;
- int base_width = 0;
- int base_height = 0;
- int xinc = 1;
- int yinc = 1;
int max_width = G_MAXINT;
int max_height = G_MAXINT;
-#define FLOOR(value, base) ( ((int) ((value) / (base))) * (base) )
-
- if ((flags & GDK_HINT_BASE_SIZE) && (flags & GDK_HINT_MIN_SIZE))
- {
- base_width = geometry->base_width;
- base_height = geometry->base_height;
- min_width = geometry->min_width;
- min_height = geometry->min_height;
- }
- else if (flags & GDK_HINT_BASE_SIZE)
+ if (flags & GDK_HINT_MIN_SIZE)
{
- base_width = geometry->base_width;
- base_height = geometry->base_height;
- min_width = geometry->base_width;
- min_height = geometry->base_height;
- }
- else if (flags & GDK_HINT_MIN_SIZE)
- {
- base_width = geometry->min_width;
- base_height = geometry->min_height;
min_width = geometry->min_width;
min_height = geometry->min_height;
}
max_height = geometry->max_height;
}
- if (flags & GDK_HINT_RESIZE_INC)
- {
- xinc = MAX (xinc, geometry->width_inc);
- yinc = MAX (yinc, geometry->height_inc);
- }
-
/* clamp width and height to min and max values
*/
width = CLAMP (width, min_width, max_width);
height = CLAMP (height, min_height, max_height);
- /* shrink to base + N * inc
- */
- width = base_width + FLOOR (width - base_width, xinc);
- height = base_height + FLOOR (height - base_height, yinc);
-
/* constrain aspect ratio, according to:
*
* width
{
int delta;
- if (flags & GDK_HINT_BASE_SIZE)
- {
- width -= base_width;
- height -= base_height;
- min_width -= base_width;
- min_height -= base_height;
- max_width -= base_width;
- max_height -= base_height;
- }
-
if (geometry->min_aspect * height > width)
{
- delta = FLOOR (height - width / geometry->min_aspect, yinc);
+ delta = height - width / geometry->min_aspect;
if (height - delta >= min_height)
height -= delta;
else
{
- delta = FLOOR (height * geometry->min_aspect - width, xinc);
+ delta = height * geometry->min_aspect - width;
if (width + delta <= max_width)
width += delta;
}
if (geometry->max_aspect * height < width)
{
- delta = FLOOR (width - height * geometry->max_aspect, xinc);
+ delta = width - height * geometry->max_aspect;
if (width - delta >= min_width)
width -= delta;
else
{
- delta = FLOOR (width / geometry->max_aspect - height, yinc);
+ delta = width / geometry->max_aspect - height;
if (height + delta <= max_height)
height += delta;
}
}
-
- if (flags & GDK_HINT_BASE_SIZE)
- {
- width += base_width;
- height += base_height;
- }
}
-#undef FLOOR
-
*new_width = width;
*new_height = height;
}
min_size = NSMakeSize (1, 1);
[self->window setContentMinSize:min_size];
- if (geom_mask & GDK_HINT_BASE_SIZE) { /* TODO */ }
-
- if (geom_mask & GDK_HINT_RESIZE_INC)
- {
- NSSize size = NSMakeSize (geometry->width_inc, geometry->height_inc);
- [self->window setContentResizeIncrements:size];
- }
-
if (geom_mask & GDK_HINT_ASPECT)
{
NSSize size;
{
GdkSurfaceHints geometry_mask = impl->geometry_mask;
- /* Ignore size increments for maximized/fullscreen surfaces */
- if (fixed_size)
- geometry_mask &= ~GDK_HINT_RESIZE_INC;
if (!saved_size)
{
/* Do not reapply constrains if we are restoring original size */
return result;
}
-static void
-adjust_drag (LONG *drag,
- LONG curr,
- int inc)
-{
- if (*drag > curr)
- *drag = curr + ((*drag + inc/2 - curr) / inc) * inc;
- else
- *drag = curr - ((curr - *drag + inc/2) / inc) * inc;
-}
-
static void
handle_wm_paint (MSG *msg,
GdkSurface *window)
gdk_event_translate (MSG *msg,
int *ret_valp)
{
- RECT rect, *drag, orig_drag;
+ RECT rect;
POINT point;
MINMAXINFO *mmi;
HWND hwnd;
case WM_SIZING:
GetWindowRect (GDK_SURFACE_HWND (window), &rect);
- drag = (RECT *) msg->lParam;
GDK_NOTE (EVENTS, g_print (" %s curr:%s drag:%s",
(msg->wParam == WMSZ_BOTTOM ? "BOTTOM" :
(msg->wParam == WMSZ_BOTTOMLEFT ? "BOTTOMLEFT" :
(msg->wParam == WMSZ_BOTTOMRIGHT ? "BOTTOMRIGHT" :
"???")))))))),
_gdk_win32_rect_to_string (&rect),
- _gdk_win32_rect_to_string (drag)));
+ _gdk_win32_rect_to_string ((RECT *) msg->lParam)));
impl = GDK_WIN32_SURFACE (window);
- orig_drag = *drag;
- if (impl->hint_flags & GDK_HINT_RESIZE_INC)
- {
- GDK_NOTE (EVENTS, g_print (" (RESIZE_INC)"));
- if (impl->hint_flags & GDK_HINT_BASE_SIZE)
- {
- /* Resize in increments relative to the base size */
- rect.left = rect.top = 0;
- rect.right = impl->hints.base_width * impl->surface_scale;
- rect.bottom = impl->hints.base_height * impl->surface_scale;
- _gdk_win32_adjust_client_rect (window, &rect);
- point.x = rect.left;
- point.y = rect.top;
- ClientToScreen (GDK_SURFACE_HWND (window), &point);
- rect.left = point.x;
- rect.top = point.y;
- point.x = rect.right;
- point.y = rect.bottom;
- ClientToScreen (GDK_SURFACE_HWND (window), &point);
- rect.right = point.x;
- rect.bottom = point.y;
-
- GDK_NOTE (EVENTS, g_print (" (also BASE_SIZE, using %s)",
- _gdk_win32_rect_to_string (&rect)));
- }
-
- switch (msg->wParam)
- {
- case WMSZ_BOTTOM:
- if (drag->bottom == rect.bottom)
- break;
- adjust_drag (&drag->bottom, rect.bottom, impl->hints.height_inc * impl->surface_scale);
- break;
-
- case WMSZ_BOTTOMLEFT:
- if (drag->bottom == rect.bottom && drag->left == rect.left)
- break;
- adjust_drag (&drag->bottom, rect.bottom, impl->hints.height_inc * impl->surface_scale);
- adjust_drag (&drag->left, rect.left, impl->hints.width_inc * impl->surface_scale);
- break;
-
- case WMSZ_LEFT:
- if (drag->left == rect.left)
- break;
- adjust_drag (&drag->left, rect.left, impl->hints.width_inc * impl->surface_scale);
- break;
-
- case WMSZ_TOPLEFT:
- if (drag->top == rect.top && drag->left == rect.left)
- break;
- adjust_drag (&drag->top, rect.top, impl->hints.height_inc * impl->surface_scale);
- adjust_drag (&drag->left, rect.left, impl->hints.width_inc * impl->surface_scale);
- break;
-
- case WMSZ_TOP:
- if (drag->top == rect.top)
- break;
- adjust_drag (&drag->top, rect.top, impl->hints.height_inc * impl->surface_scale);
- break;
-
- case WMSZ_TOPRIGHT:
- if (drag->top == rect.top && drag->right == rect.right)
- break;
- adjust_drag (&drag->top, rect.top, impl->hints.height_inc * impl->surface_scale);
- adjust_drag (&drag->right, rect.right, impl->hints.width_inc * impl->surface_scale);
- break;
-
- case WMSZ_RIGHT:
- if (drag->right == rect.right)
- break;
- adjust_drag (&drag->right, rect.right, impl->hints.width_inc * impl->surface_scale);
- break;
-
- case WMSZ_BOTTOMRIGHT:
- if (drag->bottom == rect.bottom && drag->right == rect.right)
- break;
- adjust_drag (&drag->bottom, rect.bottom, impl->hints.height_inc * impl->surface_scale);
- adjust_drag (&drag->right, rect.right, impl->hints.width_inc * impl->surface_scale);
- break;
- }
-
- if (drag->bottom != orig_drag.bottom || drag->left != orig_drag.left ||
- drag->top != orig_drag.top || drag->right != orig_drag.right)
- {
- *ret_valp = TRUE;
- return_val = TRUE;
- GDK_NOTE (EVENTS, g_print (" (handled RESIZE_INC: %s)",
- _gdk_win32_rect_to_string (drag)));
- }
- }
/* WM_GETMINMAXINFO handles min_size and max_size hints? */
geometry->max_width, geometry->max_height));
}
- if (geom_mask & GDK_HINT_BASE_SIZE)
- {
- GDK_NOTE (MISC, g_print ("... BASE_SIZE: %dx%d\n",
- geometry->base_width, geometry->base_height));
- }
-
- if (geom_mask & GDK_HINT_RESIZE_INC)
- {
- GDK_NOTE (MISC, g_print ("... RESIZE_INC: (%d,%d)\n",
- geometry->width_inc, geometry->height_inc));
- }
-
if (geom_mask & GDK_HINT_ASPECT)
{
GDK_NOTE (MISC, g_print ("... ASPECT: %g--%g\n",
if (toplevel)
{
/* These are affected by surface scale: */
- geom_mask = toplevel->last_geometry_hints_mask &
- (GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE | GDK_HINT_BASE_SIZE | GDK_HINT_RESIZE_INC);
+ geom_mask = toplevel->last_geometry_hints_mask & (GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE);
if (geom_mask)
gdk_x11_surface_set_geometry_hints (surface,
&toplevel->last_geometry_hints,
size_hints.max_height = MAX (geometry->max_height, 1) * impl->surface_scale;
}
- if (geom_mask & GDK_HINT_BASE_SIZE)
- {
- size_hints.flags |= PBaseSize;
- size_hints.base_width = geometry->base_width * impl->surface_scale;
- size_hints.base_height = geometry->base_height * impl->surface_scale;
- }
-
- if (geom_mask & GDK_HINT_RESIZE_INC)
- {
- size_hints.flags |= PResizeInc;
- size_hints.width_inc = geometry->width_inc * impl->surface_scale;
- size_hints.height_inc = geometry->height_inc * impl->surface_scale;
- }
else if (impl->surface_scale > 1)
{
size_hints.flags |= PResizeInc;
geometry->max_height = MAX (size_hints->max_height, 1) / impl->surface_scale;
}
- if (size_hints->flags & PResizeInc)
- {
- *geom_mask |= GDK_HINT_RESIZE_INC;
- geometry->width_inc = size_hints->width_inc / impl->surface_scale;
- geometry->height_inc = size_hints->height_inc / impl->surface_scale;
- }
-
if (size_hints->flags & PAspect)
{
*geom_mask |= GDK_HINT_ASPECT;
guint flags_a,
GdkGeometry *geometry_b,
guint flags_b);
-static void gtk_window_constrain_size (GtkWindow *window,
- GdkGeometry *geometry,
- guint flags,
- int width,
- int height,
- int *new_width,
- int *new_height);
static void gtk_window_update_fixed_size (GtkWindow *window,
GdkGeometry *new_geometry,
int new_width,
new_flags,
&w, &h);
gtk_window_update_fixed_size (window, &new_geometry, w, h);
- gtk_window_constrain_size (window,
- &new_geometry, new_flags,
- w, h,
- &w, &h);
+ gdk_surface_constrain_size (&new_geometry, new_flags,
+ w, h,
+ &w, &h);
info = gtk_window_get_geometry_info (window, FALSE);
geometry_a->max_height != geometry_b->max_height))
return FALSE;
- if ((flags_a & GDK_HINT_BASE_SIZE) &&
- (geometry_a->base_width != geometry_b->base_width ||
- geometry_a->base_height != geometry_b->base_height))
- return FALSE;
-
if ((flags_a & GDK_HINT_ASPECT) &&
(geometry_a->min_aspect != geometry_b->min_aspect ||
geometry_a->max_aspect != geometry_b->max_aspect))
return FALSE;
- if ((flags_a & GDK_HINT_RESIZE_INC) &&
- (geometry_a->width_inc != geometry_b->width_inc ||
- geometry_a->height_inc != geometry_b->height_inc))
- return FALSE;
-
if ((flags_a & GDK_HINT_WIN_GRAVITY) &&
geometry_a->win_gravity != geometry_b->win_gravity)
return FALSE;
return TRUE;
}
-static void
-gtk_window_constrain_size (GtkWindow *window,
- GdkGeometry *geometry,
- guint flags,
- int width,
- int height,
- int *new_width,
- int *new_height)
-{
- GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
- guint geometry_flags;
-
- /* ignore size increments for windows that fit in a fixed space */
- if (priv->maximized || priv->fullscreen || priv->tiled)
- geometry_flags = flags & ~GDK_HINT_RESIZE_INC;
- else
- geometry_flags = flags;
-
- gdk_surface_constrain_size (geometry, geometry_flags, width, height,
- new_width, new_height);
-}
-
/* For non-resizable windows, make sure the given width/height fits
* in the geometry constrains and update the geometry hints to match
* the given width/height if not.
*/
*new_flags = 0;
- /* For simplicity, we always set the base hint, even when we
- * don't expect it to have any visible effect.
- * (Note: geometry_size_to_pixels() depends on this.)
- */
- *new_flags |= GDK_HINT_BASE_SIZE;
- new_geometry->base_width = 0;
- new_geometry->base_height = 0;
-
get_shadow_width (window, &shadow);
*new_flags |= GDK_HINT_MIN_SIZE;
new_geometry->min_width = requisition.width + shadow.left + shadow.right;